#include <iostream>
#include <vector>


template <typename InIt>
InIt my_partition(InIt first, InIt last, int x) {
    while (first != last) {
        while (*first < x) {
            ++first;
            if (first==last) return first;
        }
        do {
            --last;
            if (first==last) return first;
        } while (*last >= x);
        std::iter_swap(first, last);
        ++first;
      }
      return first;
} 

template <typename T> 
void read_array(std::vector <T>* input_array) {
    int n;
    std::cin >> n;
    input_array->reserve(n);
    for (int i = 0; i < n; ++i) {
        T number; std::cin >> number;
        input_array->push_back(number);
    }
}


int main() {
    std::vector <int> input_array;
    read_array(&input_array);
    int k; std::cin >> k;
    auto middle = my_partition(input_array.begin(), input_array.end(), k);
    std::cout << std::distance(input_array.begin(), middle) << std::endl << std::distance(middle, input_array.end());
}
